<?php


/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Gmap
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
 
 
?>
<?php 
$this->headTitle('Browse Gmaps');
?>

<div class="headline">
  <h2>
    <?php echo $this->translate('Gmaps');?>
  </h2>
  <div class="tabs">
    <?php
      // Render the menu
      echo $this->navigation()
        ->menu()
        ->setContainer($this->navigation)
        ->render();
    ?>
  </div>
</div>

<div class='layout_right gmap_layout_right'>
  <div class="gmaps_gutter">
  <?php echo $this->form->render($this) ?>
    
  <?php if( $this->can_create): ?>
    <div class="quicklinks">
      <ul>
        <li>
          <a href='<?php echo $this->url(array(), 'gmap_create', true) ?>' class='buttonlink icon_gmap_new'><?php echo $this->translate('Post New Gmap');?></a>
        </li>
      </ul>
    </div>
  <?php endif; ?>
  
  </div>
</div>

<div class='layout_middle gmap_layout_middle'>

  <?php if( $this->tag || ($this->user_id && $this->user($this->user_id)->getIdentity()) || $this->search || $this->location):?>
    <div class='gmaps_result_filter_details'>
      <?php echo $this->translate('Showing gmaps posted'); ?>
      <?php if( $this->user_id && $this->user($this->user_id)->getIdentity()): ?>
        <?php echo $this->translate('by user %s', $this->htmlLink(
          $this->url(array('user'=>$this->user_id), 'gmap_browse', true),
          $this->user($this->user_id)->getTitle()
        ));?>
      <?php endif; ?>
      <?php if ($this->tag): ?>
        <?php echo $this->translate('using tag #%s', $this->htmlLink(
	        $this->url(array('tag'=>$this->tag), 'gmap_browse', true),
	        $this->tagObject ? $this->tagObject->text : $this->tag
        ));?>
      <?php endif; ?>
      <?php if ($this->search): ?>
        <?php echo $this->translate('with keyword %s', $this->htmlLink(
          $this->url(array('search'=>$this->search), 'gmap_browse', true),
          $this->search
        ));?>
      <?php endif; ?>   
      <?php if ($this->location): ?>
        <?php echo $this->translate('around location %s', $this->htmlLink(
          $this->url(array('location'=>$this->location), 'gmap_browse', true),
          $this->location
        ));?>
      <?php endif; ?>  
      <a href="<?php echo $this->url(array(), 'gmap_browse', true) ?>">(x)</a>
    </div>
  <?php endif; ?>
  
  
  <?php if( $this->paginator->getTotalItemCount() > 0 ): ?>
  
      <h3 class="sep">
        <span>
          <?php if ($this->categoryObject): ?>
            <?php echo $this->translate($this->categoryObject->category_name); ?>
            <?php $this->headTitle($this->categoryObject->category_name); ?>
          <?php else: ?>  
            <?php echo $this->translate('All Categories'); ?>
          <?php endif; ?>
        </span>
      </h3>    
  
    <div class="gmap_map_container_wrapper">
      <?php echo $this->gmapMarkers($this->google_map, $this->paginator, array('width'=>'740px','height'=>'500px')); ?>
    </div>
    
    <div class="gmaps_results">
      <h4 class="sep"><span><?php echo $this->translate(array('%s location found','%s locations found', $this->paginator->getTotalItemCount()), $this->paginator->getTotalItemCount()); ?></span></h4>
  
      <ul class="gmaps_browse">
        <?php foreach( $this->paginator as $item ): ?>
          <li>
            <?php echo $this->htmlLink($item->getHref(), $this->itemPhoto($item, 'thumb.normal')) ?>
            <div class="gmap_info">
              <div class="gmap_title">
                <?php echo $this->htmlLink($item->getHref(), $item->getTitle()) ?>
                <?php if( $item->featured ): ?>
                  <img src='application/modules/Gmap/externals/images/featured.png' class='gmap_title_icon_featured' />
                <?php endif;?>
                <?php if( $item->sponsored ): ?>
                  <img src='application/modules/Gmap/externals/images/sponsored.png' class='gmap_title_icon_sponsored' />
                <?php endif;?>
              </div>
              <div class="gmap_address">
                <?php echo $this->gmapAddressLink($this->google_map, $item)?>
              </div>
              <div class="gmap_stats">
                <?php echo $this->translate(array("%s view", "%s views", $item->view_count), $item->view_count); ?>
                - <?php echo $this->translate(array("%s comment", "%s comments", $item->comment_count), $item->comment_count); ?>
              </div>
              <div class="gmap_date"><?php echo $this->timestamp(strtotime($item->creation_date)) ?></div>
              <div class="gmap_author">
                <?php echo $this->translate('by %s', $this->htmlLink($item->getOwner()->getHref(), $item->getOwner()->getTitle()));?>
              </div>
            </div>
          </li>
        <?php endforeach; ?>
      </ul>  
  
    </div>
    <!-- /gmaps_results -->
    
    <?php echo $this->paginationControl($this->paginator, null, null, array(
      'query' => $this->formValues
    )); ?>  
    
  <?php elseif( $this->category || $this->show == 1 || $this->search || $this->user_id || $this->tag || $this->location):?>
    <div class="tip">
      <span>
        <?php echo $this->translate('Nobody has posted a gmap with that criteria.');?>
        <?php if ($this->can_create): ?>
          <?php echo $this->translate('Be the first to <a href=\'%s\'>post</a> one!', $this->url(array(), 'gmap_create')); ?>
        <?php endif; ?>
      </span>
    </div>
  <?php else:?>
    <div class="tip">
      <span>
        <?php echo $this->translate('Nobody has posted a gmap yet.');?>
        <?php if ($this->can_create): ?>
          <?php echo $this->translate('Be the first to <a href=\'%s\'>post</a> one!', $this->url(array(), 'gmap_create')); ?>
        <?php endif; ?>
      </span>
    </div>
  <?php endif; ?>
  
</div>

